package com.sky.demo.aes;

import cn.hutool.crypto.Mode;
import cn.hutool.crypto.Padding;
import cn.hutool.crypto.symmetric.AES;

import java.nio.charset.StandardCharsets;

public class AesUtils {

    public static String encrypt(String secretKey,String content) {
        AES aes = new AES(Mode.CTS, Padding.PKCS5Padding,
                secretKey.substring(0, 16).getBytes(), secretKey.substring(16).getBytes());
        return aes.encryptHex(content);
    }

    public static String decrypt(String secretKey,String content) {
        AES aes = new AES(Mode.CTS, Padding.PKCS5Padding,
                secretKey.substring(0, 16).getBytes(StandardCharsets.UTF_8), secretKey.substring(16).getBytes(StandardCharsets.UTF_8));
        return aes.decryptStr(content);
    }

    public static void main(String[] args) throws Exception {
        String decrypt = AesUtils.decrypt("c909wbtpbrw2otsdgva4albygc5miz6q", "b3c4a17d611ebbec114706e5cbb448873fe9900f549227eca21362e248d660e125e7d6a56989dae99497b0807d738a9ad84bb05f88d4ad41dbc3e98dcedb17a9985e5950c313014b3f402d8aa1c3e06f944bc6780c962db4e4b3fd5ce67158efcb0e7f25f7ac20deed1f906ee0861ef4458e70d39ce8670c441609a24b23df4d4a78d6c8f3c6738abc96b3303058fd84d6a676c203856e67775e85dd6769412bb510a8cedb4702c1e2d6230b958b7666967c32bc768b0003bb890e7996929440dccdbe0a062e77e3e7accbbb065633");
        System.out.println(decrypt);
    }
}
